package com.zzg.srb.common.Enum;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @Author zhengzg
 * @Date 2022/8/15 14:10
 * @Version 1.0
 */
@Getter
@AllArgsConstructor
public enum  SexEnum {

    /**
     * 男
     */
    MAN("男",1),

    /**
     * 女
     */
    WOMEN("女",0);

    private String name;

    private Integer value;

    /**
     * 根据枚举值获取name
     * @param value 枚举值
     * @return name
     */
    public static String getSexNameByValue(Integer value){
        for (SexEnum sex : SexEnum.values()){
            if (Objects.equals(sex.getValue(),value)){
                return sex.getName();
            }
        }
        return null;
    }
}
